package com.zyx.crawlerdemo.httpclient.crawler;

import java.net.URI;
import java.net.URISyntaxException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;

/**
 * @author Yaxi.Zhang
 * @since 2021/8/11 16:53
 * desc: httpget初始化
 */
public class HttpGetInit {
	public static void main(String[] args) throws URISyntaxException {
		// 第一种方式
		String personalUrl = "https://searchcustomerexperience.techtarget.com/info/news";
		// 创建URI
		URI uri = new URIBuilder(personalUrl).build();
		// get方法请求
		HttpGet getMethod = new HttpGet();
		// 设置
		getMethod.setURI(uri);
		System.out.println(getMethod);
		// 第二种方式
		HttpGet httpGetUri = new HttpGet(uri);
		System.out.println(httpGetUri);
		// 第三种
		HttpGet httpGetStr = new HttpGet(personalUrl);
		System.out.println(httpGetStr);
	}
}
